//
//  TripListCCell.swift
//  ImGuider X
//
//  Created by 陆涛 on 2018/9/28.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class TripListCCell: UICollectionViewCell {
    
    @IBOutlet weak var cardView: UIView!
    @IBOutlet weak var imageView: UIImageView!
    
    
    @IBOutlet weak var mengbanView: UIView!
    
    @IBOutlet weak var dateLabel: UILabel!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        cardView.layer.cornerRadius = 8
        cardView.clipsToBounds = true
    }
    
    var trip:Trip? {
        
        didSet {
            
            imageView.setImage(string: trip?.pictures, placeholder: #imageLiteral(resourceName: "placeholder_squ"))
            nameLabel.text = trip?.planName
            
            var plandate = trip?.planDate("yyyy/MM/dd")
            
            if AppManager.share.language == .english {
                
                plandate = trip?.planDate("dd MMM yyyy")
            }

            dateLabel.text = plandate
            
        }
    }
    
    override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) {
        
        super.apply(layoutAttributes)
        
        self.alpha = 1
        var alpha = layoutAttributes.alpha
        
        alpha = 1.1 - alpha
        
        self.mengbanView.backgroundColor = kMaskColor.withAlphaComponent(alpha * 1.7)
        
    }
    
}

